home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 5.4 KB | 145 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1993-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: ReadGeneva9Numbers.lib
- #
- # Version: 2.1.4
- #
- # Description: Contains tasks that retrieve the value of numbers on
- # the screen, if the font is Geneva 9. Used primarily by
- # MemoryCP.lib for reading the settings not visible to VU.
- #
- # Requires the VUAid 2.1 external tool.
- #
- # Contains:
- # readGeneva9Number()
- #
- # History:
- # Date: By: Changes:
- # 01/11/93 SBR Created
- # 09/04/95 SBR Added this header for Radar 1273927
- # 06/01/96 SBR/MSO Updated copyright header
- # 01/21/97 SBR Updated copyright header.
- #
- #########################################################################
- Libraries
- "Additions.lib",
- "Report.lib",
- "TargetControl.lib",
- "VUAid.lib",
- "VUAid.tool";
-
- #########################################################################
- # task readGeneva9Number( LT, returnString, hilite, printValues, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Reads a number on the screen in Geneva 9 plain using VUAid 2.0,
- # for example in the Memory CP and About this Macintosh windows.
- # Parameters: LT: Left Top pixel of the first digit in the number
- # (screen relative)
- # returnString: Return number as string (e.g. if theNum > 32767)
- # hilite: Number of seconds to hilite each char
- # as it is scanned (debugging)
- # printValues: Println each recognized char and
- # its checksum (debugging)
- # Returns: successful: the integer which appears on screen
- # unsuccessful: false (could not identify a character)
- # Examples: kDiskCacheSizeLT := { 284, 36 };
- # readGeneva9Number( kDiskCacheSizeLT );
- # Assumptions: number is visible in front window
- # checksums are available for 1,2,4,8,16 and 32-bit depth
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/11/93 SBR Created
- # 04/28/93 SBR Added 2,4,16-bit checksums
- # 05/31/93 SBR Added 32-bit checksums; checked 24 & 32-bit addressing with VUAid 2.0a7
- # 06/25/93 SBR Added returnString parameter for RAM Disk > 32767K
- #########################################################################
- task ReadGeneva9Number( LT, returnString := false, hilite := false,
- printValues := false, v_level := 5 )
- begin
- checkSums :=
- {
- { 1, { { 21824,'1' }, { 24560,'2' }, { -480,'3' }, { -30816,'4' }, { -5600,'5' },
- { -29152,'6' }, { 27968,'7' }, { -25056,'8' }, { -29120,'9' }, { -21984,'0' },
- { 14736,'K' }, { -13056,'M' }, { 0,'' } }},
- { 2, { { 1530,'1' }, { -27610,'2' }, { -9874,'3' }, { -14536,'4' }, { -13570,'5' },
- { -32626,'6' }, { -14422,'7' }, { -24946,'8' }, { -24562,'9' }, { -26722,'0' },
- { 31800,'K' }, { 18432,'M' }, { 0,'' } }},
- { 4, { { 19170,'1' }, { 6194,'2' }, { 26654,'3' }, { 6584,'4' }, { 20414,'5' },
- { -7546,'6' }, { 14354,'7' }, { 9974,'8' }, { 10454,'9' }, { 2534,'0' },
- { 26520,'K' }, { -26206,'M' }, { 0,'' } }},
- { 8, { { 15554,'1' }, { 17338,'2' }, { 8922,'3' }, { -29582,'4' }, { 25242,'5' },
- { -17342,'6' }, { -1278,'7' }, { -29838,'8' }, { -29328,'9' }, { 31618,'0' },
- { -1532,'K' }, { -13262,'M' }, { 0,'' } }},
- { 16, { { -2920,'1' }, { 27304,'2' }, { 7272,'3' }, { 32056,'4' }, { -17176,'5' },
- { 13720,'6' }, { 22552,'7' }, { -200,'8' }, { -964,'9' }, { 5912,'0' },
- { -9964,'K' }, { 7608,'M' }, { -12516,'' } }},
- { 32, { { -2588,'1' }, { -7940,'2' }, { 17308,'3' }, { 1748,'4' }, { -31652,'5' },
- { 30564,'6' }, { -17628,'7' }, { 2516,'8' }, { 986,'9' }, { 14756,'0' },
- { -16866,'K' }, { 18324,'M' }, { -21462,'' } }}
- };
- charSize := { 7,8 };
- RStatus("readGeneva9Number with LT = {LT}, hilite = {hilite}, printValues = {printValues}",v_level);
- c1 := offset_list({0,0} + charSize,LT);
- bitDepth := ensure_screen_depth({ 1,2,4,8,16,32 });
- if not bitDepth
- begin
- return RIncomplete('readGeneva9Number: Can not set depth to one of { 1,2,4,8,16,32 }');
- end;
- else
- bitDepth := bitDepth[2];
-
- theNum := '';
- endLoop := false;
- i := 0;
- while not done
- begin
- hOffset := i * 6; # offset to ith digit
- c := { hOffset + c1[1], c1[2], hOffset + c1[3], c1[4] };
-
- if hilite >= 0
- begin
- VUAid('InvertScreenRect', { c[1], c[2], c[3], c[4] });
- wait(hilite);
- VUAid('InvertScreenRect', { c[1], c[2], c[3], c[4] });
- end;
-
- chkSum := VUAid('CompareScreenRect', { c[1], c[2], c[3], c[4] });
- nextChar := assoc(chkSum, assoc(bitDepth,checkSums));
- if printValues
- println "nextChar: {nextChar} checkSum: {chkSum}";
- if not (nextChar or theNum)
- begin
- theNum := ''; # not a digit, 'K', 'M', or '' before the first digit
- done := true;
- end;
- else if nextChar = 'K' or nextChar = 'M' or nextChar = ''
- done := true;
- else
- begin
- theNum := theNum + nextChar;
- end;
- i := i + 1;
- end;
-
- if not theNum
- begin
- return RIncomplete("readGeneva9Number: bad number is '{theNum}'", v_level);
- end;
-
- if returnString
- rtnStrMsg := ' as a string';
- else
- begin
- theNum := strToNum(theNum);
- rtnStrMsg := ' as an integer';
- end;
- RStatus("readGeneva9Number: returned {theNum}{rtnStrMsg}",v_level);
- return theNum;
- end;
-
-